﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web.Security;
using EzDesk.Core.Interface;
using EzDesk.Core.Model;
using EzDesk.Core.ServiceImpl;
using EzDesk.Core.ServiceImpl.Repositories;
using EzDesk.Core.ServiceImpl.Repositories.Interface;
using EzDesk.Core.ServiceImpl.Services;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using NUnit.Framework;
using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert;

namespace EzDesk.Core.UnitTest
{
    /// <summary>
    /// Summary description for CoreClientServiceFixture
    /// </summary>
    [TestFixture]
    public class CoreClientServiceFixture
    {
        private Mock<ICoreService> mock_ICoreService;
        private Mock<IOperationProperties> mock_IOperationProperties;
        private Mock<IAppFunctionRepository> mock_IAppFunctionRepository;


        private CoreClientService _coreClientService;


        public CoreClientServiceFixture()
        {
            //
            // TODO: Add constructor logic here
            //
        }


        [SetUp]
        public void SetUp()
        {
            mock_ICoreService = new Mock<ICoreService>();
            mock_IOperationProperties = new Mock<IOperationProperties>();
            mock_IAppFunctionRepository = new Mock<IAppFunctionRepository>();

            
            this._coreClientService = new CoreClientService(
                mock_ICoreService.Object
                ,mock_IOperationProperties.Object
                ,mock_IAppFunctionRepository.Object
                );

        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion



        [Test]
        public void Test_获得公司信息()
        {
            var db = new EzDeskDataContext();
            var _coreService = new CoreService(new UserRepository(db), new DeptRepository(db), new AppRepository(db), new PositionRepository(db), new GroupRepository(db), new FeedRepository(db),  new PermissionRepository(db), new OrganizationRepository(db));
            var _coreClientService = new CoreClientService(
                _coreService, mock_IOperationProperties.Object,
                mock_IAppFunctionRepository.Object
                );

            Organization organization = _coreClientService.GetOrganizationInfo();

            Assert.AreEqual(organization.Title, "上海魏玛");
        }
    }
}
